<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-mpChannelIp-add">
			<input type="hidden" id="channelId" name="channelId" th:value="${mpChannel.id}">
			<div class="form-group">	
				<label class="col-sm-2 control-label" >IP：</label>
				<div class="col-sm-8" >
					<input id="ip" name="ip" class="form-control" type="text" required>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "channel/mpChannelIp"
		$("#form-mpChannelIp-add").validate({
			rules:{
                ip:{
                    remote:{
                        url:prefix + "/checkIpUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "channelId":function () {
                                return $.common.trim($("#channelId").val());
                            },
                            "ip":function () {
                                return $.common.trim($("#ip").val());
                            }
                        },
                        dataFilter: function(data, type) {
                            return $.validate.unique(data);
                        }
					}
				}
			},
            messages: {
                "ip": {
                    remote: "该渠道已添加该IP地址"
                }
            },
			focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/addIp", $('#form-mpChannelIp-add').serialize());
	        }
	    }
	</script>
</body>
</html>
